package fasilkom.antz.gui;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Transparency;
import java.awt.image.BufferedImage;

import com.golden.gamedev.gui.theme.basic.BPanelRenderer;
import com.golden.gamedev.gui.toolkit.GraphicsUtil;
import com.golden.gamedev.gui.toolkit.TComponent;


/**
 * Custom panel renderer with translucent option.
 *
 */
public class CustomPanelRenderer extends BPanelRenderer {
	
	@Override
	public BufferedImage[] createUI(TComponent component, int w, int h) {
		BufferedImage[] ui = GraphicsUtil.createImage(2, w, h, Transparency.TRANSLUCENT);
		String[] color = new String[] {
			"Background Color", "Background Disabled Color"
		};
		Color borderColor = (Color) get("Background Border Color", component);
		for (int i=0;i < ui.length;i++) {
			Graphics2D g = ui[i].createGraphics();
			g.setColor((Color) get(color[i], component));
			if (borderColor == null) {
				g.fill3DRect(0, 0, w, h, true);
			} else { // borderColor != null
				g.fill3DRect(0, 0, w-1, h-1, true);
				g.setColor(borderColor);
				g.drawRect(0, 0, w-1, h-1);
			}
			g.dispose();
		}
		return ui;
	}
}